import Vue from 'vue'
import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 在请求拦截器中，展示进度条NProgress.start()
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  NProgress.start()
  return config
})
// 在响应拦截器中，隐藏进度条 NProgress.remove()
axios.interceptors.response.use(config => {
  NProgress.done()
  NProgress.remove()
  return config
})
